package CutLoad.components.loadbar
{
	import CutLoad.Base;
	import CutLoad.CutLoad;
	import CutLoad.components.container.Container;
	import CutLoad.cookies.CLoadImg;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import CutLoad.cookies.CLoader;

	/**
	 * 带有图片背景的加载进度条 
	 * @author smallerbird mail:smallerbird@gmail.com  site:www.mkigm.com QQ群:49983196
	 * 
	 */	
	public class LoadbarHaveBack extends Base implements ILoadBar
	{
		private var bak:CLoader
		private var container:Container
		private var loadBar:Loadbar
		private var showWidth:Number,showHeight:Number
		//
		private var clone_url:String;
		private var clone_w:Number;
		private var clone_h:Number;
		private var clone_loadBar:Loadbar;
		/**
		 * 
		 * @param url 加载图片地址
		 * @param w 宽
		 * @param h 高
		 * @param loadBar 加载的进度条,注：传递的这个ILoadBar实例，将会被克隆一份，同时设置的位置也是该实例的x,y，所以传进去之前可以先设置x,y
		 * 
		 */		
		public function LoadbarHaveBack(url:String,w:Number,h:Number,loadBarForClone:Loadbar):void
		{
			clone_url=url;
			clone_w=w;
			clone_h=h;
			clone_loadBar=loadBarForClone;
			//
			bak=new CLoader(url,w,h);
			bak.setMask();
			bak.show(this);
			this.loadBar=loadBarForClone.clone() as Loadbar;
			this.loadBar.setXY(loadBarForClone.x,loadBarForClone.y,this);
			//
			showWidth=w;
			showHeight=h;
		}
		/**
		 * 更新加载信息 
		 * 
		 */		
		public function dreawing():void{
			loadBar.dreawing();
		}
		/**
		 * 克隆 
		 * @return 
		 * 
		 */		
		public function clone():ILoadBar{
			var loadBarTem123:Loadbar=clone_loadBar.clone() as Loadbar
			loadBarTem123.x=clone_loadBar.x;
			loadBarTem123.y=clone_loadBar.y;
			return new LoadbarHaveBack(clone_url,clone_w,clone_h,loadBarTem123);
		}
		/**
		 * 设置加载进分比 
		 * @param per
		 * @param strTalkYou
		 * 
		 */		
		public function setValue(per:Number,strTalkYou:String):void{
			//trace("LoadbarHaveBack.setValue "+per+" "+strTalkYou)
			loadBar.setValue(per,strTalkYou);
		}
		/**
		 * 显示或隐藏 
		 * @param isShow
		 * 
		 */		
		public function showHide(isShow:Boolean):void{
			this.visible=isShow;
		}
		/**
		 * 获得显示的宽 
		 * @return 
		 * 
		 */		
		override public function getShowWidth():Number{
			return showWidth;
		}
		/**
		 * 获得显示的高 
		 * @return 
		 * 
		 */		
		override public function getShowHeight():Number{
			return this.showHeight;
		}
		/**
		 * 设置当加载完成后，要运行一个方法。 
		 * @param fun
		 * 
		 */		
		public function setLoadCompleteDo(fun:Function):void{
			
		}
		/**
		 * 当加载完成后，是否要运行一个方法
		 * @return 
		 * 
		 */		
		public function isLoadCompleteDo():Boolean{
			return false;
		}
		/**
		 * 加载完成时调用这个方法
		 * 
		 */				
		public function loadComplete():void{
			
		}
	}
}